/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bio.jpa.entities;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Diego
 */
@Entity
@Table(name = "group_previlege", catalog = "biodb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "GroupPrevilege.findAll", query = "SELECT g FROM GroupPrevilege g"),
    @NamedQuery(name = "GroupPrevilege.findByCanRead", query = "SELECT g FROM GroupPrevilege g WHERE g.canRead = :canRead"),
    @NamedQuery(name = "GroupPrevilege.findByCanWrite", query = "SELECT g FROM GroupPrevilege g WHERE g.canWrite = :canWrite"),
    @NamedQuery(name = "GroupPrevilege.findByCanDelete", query = "SELECT g FROM GroupPrevilege g WHERE g.canDelete = :canDelete"),
    @NamedQuery(name = "GroupPrevilege.findByGidFk", query = "SELECT g FROM GroupPrevilege g WHERE g.gidFk = :gidFk")})
public class GroupPrevilege implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @Column(name = "can_read")
    private boolean canRead;
    @Basic(optional = false)
    @Column(name = "can_write")
    private boolean canWrite;
    @Basic(optional = false)
    @Column(name = "can_delete")
    private boolean canDelete;
    @Id
    @Basic(optional = false)
    @Column(name = "gid_fk")
    private Integer gidFk;
    @JoinColumn(name = "gid_fk", referencedColumnName = "gr_id", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private UserGroup userGroup;

    public GroupPrevilege() {
    }

    public GroupPrevilege(Integer gidFk) {
        this.gidFk = gidFk;
    }

    public GroupPrevilege(Integer gidFk, boolean canRead, boolean canWrite, boolean canDelete) {
        this.gidFk = gidFk;
        this.canRead = canRead;
        this.canWrite = canWrite;
        this.canDelete = canDelete;
    }

    public boolean getCanRead() {
        return canRead;
    }

    public void setCanRead(boolean canRead) {
        this.canRead = canRead;
    }

    public boolean getCanWrite() {
        return canWrite;
    }

    public void setCanWrite(boolean canWrite) {
        this.canWrite = canWrite;
    }

    public boolean getCanDelete() {
        return canDelete;
    }

    public void setCanDelete(boolean canDelete) {
        this.canDelete = canDelete;
    }

    public Integer getGidFk() {
        return gidFk;
    }

    public void setGidFk(Integer gidFk) {
        this.gidFk = gidFk;
    }

    public UserGroup getGroup1() {
        return userGroup;
    }

    public void setGroup1(UserGroup group1) {
        this.userGroup = group1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (gidFk != null ? gidFk.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GroupPrevilege)) {
            return false;
        }
        GroupPrevilege other = (GroupPrevilege) object;
        if ((this.gidFk == null && other.gidFk != null) || (this.gidFk != null && !this.gidFk.equals(other.gidFk))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bio.jpa.entities.GroupPrevilege[ gidFk=" + gidFk + " ]";
    }
    
}
